package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.dto.UserNoticeCountDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysUserNoticeMapper;
import com.ruoyi.system.domain.SysUserNotice;
import com.ruoyi.system.service.ISysUserNoticeService;

/**
 * 用户消息Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-07-15
 */
@Service
public class SysUserNoticeServiceImpl implements ISysUserNoticeService 
{
    @Autowired
    private SysUserNoticeMapper sysUserNoticeMapper;

    /**
     * 查询用户消息
     * 
     * @param id 用户消息ID
     * @return 用户消息
     */
    @Override
    public SysUserNotice selectSysUserNoticeById(Long id)
    {
        return sysUserNoticeMapper.selectSysUserNoticeById(id);
    }

    /**
     * 查询用户消息列表
     * 
     * @param sysUserNotice 用户消息
     * @return 用户消息
     */
    @Override
    public List<SysUserNotice> selectSysUserNoticeList(SysUserNotice sysUserNotice)
    {
        return sysUserNoticeMapper.selectSysUserNoticeList(sysUserNotice);
    }

    /**
     * 新增用户消息
     * 
     * @param sysUserNotice 用户消息
     * @return 结果
     */
    @Override
    public int insertSysUserNotice(SysUserNotice sysUserNotice)
    {
        sysUserNotice.setCreateTime(DateUtils.getNowDate());
        return sysUserNoticeMapper.insertSysUserNotice(sysUserNotice);
    }

    /**
     * 修改用户消息
     * 
     * @param sysUserNotice 用户消息
     * @return 结果
     */
    @Override
    public int updateSysUserNotice(SysUserNotice sysUserNotice)
    {
        sysUserNotice.setUpdateTime(DateUtils.getNowDate());
        return sysUserNoticeMapper.updateSysUserNotice(sysUserNotice);
    }

    /**
     * 批量删除用户消息
     * 
     * @param ids 需要删除的用户消息ID
     * @return 结果
     */
    @Override
    public int deleteSysUserNoticeByIds(Long[] ids)
    {
        return sysUserNoticeMapper.deleteSysUserNoticeByIds(ids);
    }

    /**
     * 删除用户消息信息
     * 
     * @param id 用户消息ID
     * @return 结果
     */
    @Override
    public int deleteSysUserNoticeById(Long id)
    {
        return sysUserNoticeMapper.deleteSysUserNoticeById(id);
    }


    /**
     * 全部设置为已读
     * @param createUser
     * @return
     */
    @Override
    public int updateIsReadAll(Long createUser){
        return sysUserNoticeMapper.updateIsReadAll(createUser);

    }
    @Override
    public List<UserNoticeCountDTO> selectUnreadCountByUserId(Long createUser){
        return sysUserNoticeMapper.selectUnreadCountByUserId(createUser);
    }

}
